-
Notifications
You must be signed in to change notification settings - Fork 12
Improve test coverage #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
self.assertRegexpMatches(line, r"^(5a6,13$|>)") | ||
|
||
|
||
class TestBootloaderAdHoc(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if grub1 and extlinux are actually used nowadays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I too, but the code is still there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grub1 maybe not. extlinux, yes :-(
|
||
class TestAccessor(unittest.TestCase): | ||
def test_http(self): | ||
raise unittest.SkipTest("comment out if you really mean it") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain this in the commit message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
General comment: a few commit titles are longer than 70 chars (at XCP-ng it's the limit we try not to cross, and that's also when github starts eliding the displayed title). I think you could easily avoid it in most cases by simply prefixing the titles with "Coverage:" rather than "Improve coverage:" (maybe you'll also have to save a few chars here and there too). |
c1e4eba
to
daeca57
Compare
daeca57
to
e1474df
Compare
should be OK now |
d4acc74
to
e314350
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really happy to see the tests being improved so much, even catching some bugs. I had a comment but it's not really related to the tests
# CpioFileCompat testing | ||
|
||
def archiveExtractCompat(self, fn, comp): | ||
arc = CpioFileCompat(fn, mode="r", compression={"": CPIO_PLAIN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an enhancement it'd be nice to get a context manager to close the resource when reaching the end of the scope instead of forcing users to close them every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agree. This feature has been added to tarfile.py
in python3, and we should be able to get it, likely together with other goodies, but we would first have to sync with the 2.7 version, and we don't even have a clue which version was used as a base for this work :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python 2.2. Please do feel free to nuke P <2.7-isms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but that will likely be for a separate PR, let's not mix this with the tests stuff :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to stay as close to upstream as possible, and get the <2.7-isms removed from cpython's tarfile
first. We'll then get them into cpiofile
by merging newer upstream versions.
e314350
to
af3e5a0
Compare
Adds more data to the archive (a copy of the same file, from another wd). Uses the "." special case for even more coverage. Coverage change: xcp.cpiofile: 50% -> 51.7% total: 38.4% -> 39% Signed-off-by: Yann Dirson <[email protected]>
Coverage change: xcp.cpiofile: 51.7% -> 58.1% total: 39% -> 41.1% Signed-off-by: Yann Dirson <[email protected]>
Coverage change: xcp.pci: 40.9% -> 76.3% total: 41.1% -> 43% Signed-off-by: Yann Dirson <[email protected]>
Coverage change: xcp.cmd: 0% -> 78.0% total: 43% -> 44.2% Signed-off-by: Yann Dirson <[email protected]>
Coverage change: xcp.xmlunwrap: 0% -> 68.6%% total: 44.2% -> 45.2% Signed-off-by: Yann Dirson <[email protected]>
We may want to do some real checks on the output, this first version only exercises the code. Includes ad-hoc testing of write/read methods for grub/extlinux from a grub2 configuration, for lack of representative versions of those deprecated config files. Ad-hoc test for extlinux reveals inconsistent typing, and is marked as failing for now: print("serial %d %d" % (self.serial['port'], > self.serial['baud']), file=fh) E TypeError: %d format: a number is required, not str Coverage change: xcp.bootloader: 0% -> 59.1%% total: 45.2% -> 53.4% Signed-off-by: Yann Dirson <[email protected]>
File format parsers do not all agree whether to store some parameters as int or str. This relax the format strings to accept both. Fixes creating an extlinux config from a grub2 config. Coverage change: xcp.bootloader: 59.1% -> 72.8% total: 53.4% -> 55.3% Signed-off-by: Yann Dirson <[email protected]>
89011f4
to
d38a648
Compare
Only FileAccessor is actually covered by these tests. HTTPAccessor tests are provided, but are skipped by default, as they currently need network access to xcp-ng.org repository. We will want at some point to mock the HTTP access. Coverage change: xcp.accessor: 0% -> 30.0% xcp.repository: 0% -> 72.2% total: 55.3% -> 62.7% Signed-off-by: Yann Dirson <[email protected]>
Coverage change: xcp.environ: 0% -> 80.0% total: 62.7% -> 63.3% Signed-off-by: Yann Dirson <[email protected]>
Direct test execution only brings us dependency on `sys` :) Signed-off-by: Yann Dirson <[email protected]>
Coverage change: xcp.net.biosdevname: 41.5% to 87.8% total: 63.3% -> 63.8% Signed-off-by: Yann Dirson <[email protected]>
This function is private, not called, and if called would not do what the docstring says (does not pass "eth" as argument to the command called). Coverage change: xcp.net.biosdevname: 87.8% -> 94.6% total: 63.8% -> 63.9% Signed-off-by: Yann Dirson <[email protected]>
Coverage change: xcp.cpiofile: 58.1% -> 62.1% total: 63.9% -> 65.2% Signed-off-by: Yann Dirson <[email protected]>
Coverage change: xcp.bootloader: 72.8% -> 81.9% total: 65.4% -> 66.6% Signed-off-by: Yann Dirson <[email protected]>
Signed-off-by: Yann Dirson <[email protected]>
d38a648
to
056238e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes/introduces test code, except for:
- removal of some main from certain files and moving it into test code (ok)
- changing some formats from %d to %s, apparently this fixes a bug in a unit test that previously was marked as FIXME, so this should be fine
…5506-improve-tests CP-45506: Verify that /etc/systemd does not have files(moved to tarball)
This brings the test coverage from 38.4% to 66.6%, to help in checking the port to python3.